﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;

namespace Quebec.Silverlight.Controls.WindowControls
{
	public class MaximizeButton : Button
	{
		public MaximizeButton()
		{
			this.DefaultStyleKey = typeof(MaximizeButton);

			this.MouseEnter += (se, ea) => VisualStateManager.GoToState(this, "MouseEnter", true);
			this.MouseLeave += (se, ea) => VisualStateManager.GoToState(this, "MouseLeave", true);

			this.Click += (se, ea) =>
				{
					if (Application.Current.HasElevatedPermissions)
					{
						if (Application.Current.MainWindow.WindowState == WindowState.Normal)
						{
							Application.Current.MainWindow.WindowState = WindowState.Maximized;
						}
						else
						{
							Application.Current.MainWindow.WindowState = WindowState.Normal;
						}
					}
				};
		}
	}
}
